<template>
	<div>
		类型自定义: 1=轮播图 2=广告图 3=新品图
		<div style="width: 100%;">
			类型:<el-input v-model="hot.type" type="text" placeholder="请输入内容"></el-input>
		</div>
		<hr>
		<div style="width: 100%;">
			数字越大，显示在前面
			热度:<el-input v-model="hot.hot" type="text" placeholder="请输入内容"></el-input>
		</div>
		<div style="width: 100%;">
			描述：<el-input v-model="hot.memo" type="text" placeholder="请输入内容"></el-input>
		</div>
		<div style="width: 10vw; height: 10vw;">
			图片:<input type="file" ref="imgs" id="pic">
			<hr>
		<div style="display: flex; justify-content: center;">
			<el-button type="primary" @click="update()" size="small" style="width: 200px;"> 修改</el-button>
		</div>	
		</div>
	</div>
</template>

<script>
	export default{
		name:'updatePic',
		data() {
			return{
				act: 2,
				hot: {},
			}
		},
		methods: {
			goupdate(id) {
				this.act = 0;
				let token = window.localStorage.getItem("token")
				let _this = this;
				this.$get("/api/adm/hot/findById/" + id)
					.then((resp) => {
						_this.hot = resp.data.data;
						console.log(resp.data.data);
					})
			},
			update() {
				let fd = new FormData
				fd.append("id", this.hot.id)
				fd.append("memo", this.hot.memo)
				fd.append("hot",this.hot.hot)
				fd.append("picture", this.hot.picture)
				fd.append("type", this.hot.type)
				console.log(fd);
				let pic = this.$refs.imgs.files[0]
				fd.append("pic", pic)
				let _this = this;
				this.$postf(
						"/api/adm/hot/add", fd,
					)
					.then((resp) => {
						_this.hot = resp.data.data;
						console.log(resp.data.data);
						this.$router.push({
							path: '/PC/hotPic',
							query: {
								id: this.hot.id
							}
						})
					})
			},
		},
		mounted() {
			let m = this.$route.query.hot
			console.log(m);
			this.goupdate(m)
		}
	}
</script>

<style>
</style>